import api from "@/apis/index.js"
import localStore from '@/common/localStore.js'

/**
 * 新增工艺
 * @param {Object} data
 */
export function addProcess(data) {
	return api.requestNoTokenPOST(1, 1, {
		url: getUrl() + "/api/Craft/Add",
		data: data
	})
}

/**
 * 取点
 * @param {Object} data
 */
export function getPoint() {
	return api.requestNoTokenGET(1, 1, {
		url: getUrl() + "/api/Robot/GetRokaePoint",
		data: {}
	})
}

/**
 * 新增模板
 * @param {Object} data
 */
export function saveTemplate(data) {
	return api.requestNoTokenPOST(1, 1, {
		url: getUrl() + "/api/WeldingTemplate/Add",
		data: data
	})
}

/**
 * 获取模板列表
 * @param {Object} data
 */
export function getTemplateList(data) {
	return api.requestNoTokenGET(1, 1, {
		url: getUrl() + "/api/WeldingTemplate/GetTemplateTaskList",
		data: data
	})
}

/**
 * 模板焊接
 * @param {Object} data
 */
export function startTemplateWelding(id, type) {
	return api.requestNoTokenPOST(1, 1, {
		url: getUrl() + "/api/Welding/TemplateWelding?id=" + id + "&weldStartType=" + type,
		data: {}
	})
}

/**
 * 获取模板详情
 * @param {Object} data
 */
export function getTemplateDetail(data) {
	return api.requestNoTokenGET(1, 1, {
		url: getUrl() + "/api/WeldingTemplate/GetTemplateTaskById",
		data: data
	})
}

/**
 * 模板修改
 * @param {Object} data
 */
export function updateHandTemplate(data) {
	return api.requestNoTokenPOST(1, 1, {
		url: getUrl() + "/api/WeldingTemplate/Update",
		data: data
	})
}

/**
 * 模板删除
 * @param {Object} data
 */
export function delHandTemplate(data) {
	return api.requestNoTokenGET(1, 1, {
		url: getUrl() + "/api/WeldingTemplate/Delete",
		data: data
	})
}

/**
 * 获取工艺列表
 * @param {Object} data
 */
export function getCraftList(data) {
	return api.requestNoTokenGET(1, 1, {
		url: getUrl() + "/api/Craft/GetAll",
		data: data
	})
}

/**
 * 工艺删除
 * @param {Object} data
 */
export function delCraft(id) {
	return api.requestNoTokenDelete(1, 1, {
		url: getUrl() + "/api/Craft/Delete/" + id,
		data: {}
	})
}

/**
 * 获取工艺详情
 * @param {Object} data
 */
export function getProcessDetail(data) {
	return api.requestNoTokenGET(1, 1, {
		url: getUrl() + "/api/Craft/Get/" + data,
		data: {}
	})
}

/**
 * 更新工艺名称
 * @param {Object} data
 */
export function updateProcessName(id, data) {
	return api.requestNoTokenPut(1, 1, {
		url: getUrl() + "/api/Craft/UpdateCraftName/" + id,
		data: data
	})
}

/**
 * 更新工艺1
 * @param {Object} data
 */
export function updateArcStartParam(id, data) {
	return api.requestNoTokenPut(1, 1, {
		url: getUrl() + "/api/Craft/UpdateArcStartParams/" + id,
		data: data
	})
}

/**
 * 更新工艺2
 * @param {Object} data
 */
export function updateArcEndParam(id, data) {
	return api.requestNoTokenPut(1, 1, {
		url: getUrl() + "/api/Craft/UpdateArcEndParams/" + id,
		data: data
	})
}

/**
 * 更新工艺3
 * @param {Object} data
 */
export function updateWeldingParam(id, data) {
	return api.requestNoTokenPut(1, 1, {
		url: getUrl() + "/api/Craft/UpdateWeldingParams/" + id,
		data: data
	})
}

/**
 * 更新工艺4
 * @param {Object} data
 */
export function updateWeaveParam(id, data) {
	return api.requestNoTokenPut(1, 1, {
		url: getUrl() + "/api/Craft/UpdateWeaveParams/" + id,
		data: data
	})
}

/**
 * 更新工艺5
 * @param {Object} data
 */
export function updateArcTrackingParam(id, data) {
	return api.requestNoTokenPut(1, 1, {
		url: getUrl() + "/api/Craft/UpdateArcTrackingParams/" + id,
		data: data
	})
}

/**
 * 更新工艺6
 * @param {Object} data
 */
export function updateMotionParam(id, data) {
	return api.requestNoTokenPut(1, 1, {
		url: getUrl() + "/api/Craft/UpdateMotionParams/" + id,
		data: data
	})
}

/**
 * 更新工艺7
 * @param {Object} data
 */
export function updateArcRestartParam(id, data) {
	return api.requestNoTokenPut(1, 1, {
		url: getUrl() + "/api/Craft/UpdateArcRestartParams/" + id,
		data: data
	})
}

/**
 * 更新工艺8
 * @param {Object} data
 */
export function updateCornerWeldingParam(id, data) {
	return api.requestNoTokenPut(1, 1, {
		url: getUrl() + "/api/Craft/UpdateCornerWeldingParams/" + id,
		data: data
	})
}

/**
 * 更新工艺9
 * @param {Object} data
 */
export function updateCornerWeaveParam(id, data) {
	return api.requestNoTokenPut(1, 1, {
		url: getUrl() + "/api/Craft/UpdateCornerWeaveParams/" + id,
		data: data
	})
}

/**
 * 示教焊接
 * @param {Object} data
 */
export function startTeachWelding(data) {
	return api.requestNoTokenPOST(1, 1, {
		url: getUrl() + "/api/Welding/HandMoveWelding",
		data: data
	})
}

/**
 * 获取logo
 * @param {Object} data
 */
export function getLogoImgUrl() {
	return api.requestNoTokenGET(1, 1, {
		url: getUrl() + "/api/LogoUpload/GetLogoUrl",
		data: {}
	})
}

/**
 * 获取ip
 * @param {Object} data
 */
export function getIp() {
	return api.requestNoTokenGET(1, 1, {
		url: getUrl() + "/api/SetIP/GetSetIP",
		data: {}
	})
}

/**
 * 新增IP
 * @param {Object} data
 */
export function addIp(data) {
	return api.requestNoTokenPOST(1, 1, {
		url: getUrl() + "/api/SetIP/Add",
		data: data
	})
}

/**
 * 更新IP
 * @param {Object} data
 */
export function updateIp(data) {
	return api.requestNoTokenPOST(1, 1, {
		url: getUrl() + "/api/SetIP/Update",
		data: data
	})
}

/**
 * 开启拖动
 * @param {Object} data
 */
export function startDragMove(data) {
	return api.requestNoTokenGET(1, 1, {
		url: getUrl() + "/api/Robot/SetDragEnable",
		data: data
	})
}

/**
 * 停止拖动
 * @param {Object} data
 */
export function stopDragMove(data) {
	return api.requestNoTokenGET(1, 1, {
		url: getUrl() + "/api/Robot/SetDragDisable",
		data: data
	})
}

/**
 * 急停恢复
 * @param {Object} data
 */
export function resumeState(data) {
	return api.requestNoTokenGET(1, 1, {
		url: getUrl() + "/api/Robot/RecoverState",
		data: data
	})
}

/**
 * 停止移动
 * @param {Object} data
 */
export function stopCommond(data) {
	return api.requestNoTokenGET(1, 1, {
		url: getUrl() + "/api/Robot/StopCommand",
		data: data
	})
}

/**
 * 清除移动
 * @param {Object} data
 */
export function clearCommond(data) {
	return api.requestNoTokenGET(1, 1, {
		url: getUrl() + "/api/Robot/DeleteCommand",
		data: data
	})
}

/**
 * 重新执行
 * @param {Object} data
 */
export function reStartTask(data) {
	return api.requestNoTokenGET(1, 1, {
		url: getUrl() + "/api/Robot/ReStart",
		data: data
	})
}

/**
 * 继续执行
 * @param {Object} data
 */
export function continuTask(data) {
	return api.requestNoTokenGET(1, 1, {
		url: getUrl() + "/api/Robot/RecoverState",
		data: data
	})
}

/**
 * 获取焊接类型
 * @param {Object} data
 */
export function getWeldingTypeDictData(data) {
	return api.requestNoTokenGET(1, 1, {
		url: getUrl() + "/api/BaseData/GetSeamType",
		data: data
	})
}

/**
 * 获取多层多道
 * @param {Object} data
 */
export function getMultiChannel(data) {
	return api.requestNoTokenGET(1, 1, {
		url: getUrl() + "/api/MultiLayerTrack/GetMultiLayerTrackByType",
		data: data
	})
}

/**
 * 保存多层多道
 * @param {Object} data
 */
export function saveMultiChannel(data) {
	return api.requestNoTokenPOST(1, 1, {
		url: getUrl() + "/api/MultiLayerTrack/Add",
		data: data
	})
}

/**
 * 更新多层多道
 * @param {Object} data
 */
export function updateMultiChannel(data) {
	return api.requestNoTokenPOST(1, 1, {
		url: getUrl() + "/api/MultiLayerTrack/Update",
		data: data
	})
}

/**
 * 多层多道焊接
 * @param {Object} data
 */
export function multiChannelWelding(data) {
	return api.requestNoTokenGET(1, 1, {
		url: getUrl() + "/api/Welding/MultiLayerWelding",
		data: data
	})
}

function getUrl() {
	if (api.isUserNetworkFunViewConfig) {
		return localStore.getHttpRequestUrl()
	} else {
		return api.baseUrl
	}
}

export default {
	addProcess,
	getPoint,
	saveTemplate,
	getTemplateList,
	startTemplateWelding,
	getTemplateDetail,
	updateHandTemplate,
	delHandTemplate,
	getCraftList,
	delCraft,
	getProcessDetail,
	updateProcessName,
	updateArcStartParam,
	updateArcEndParam,
	updateWeldingParam,
	updateWeaveParam,
	updateArcTrackingParam,
	updateMotionParam,
	updateArcRestartParam,
	updateCornerWeldingParam,
	updateCornerWeaveParam,
	startTeachWelding,
	getLogoImgUrl,
	getIp,
	addIp,
	updateIp,
	startDragMove,
	stopDragMove,
	resumeState,
	stopCommond,
	clearCommond,
	reStartTask,
	continuTask,
	getWeldingTypeDictData,
	getMultiChannel,
	saveMultiChannel,
	updateMultiChannel,
	multiChannelWelding
}